package com.nanhang.listener;

import com.alibaba.otter.canal.protocol.CanalEntry;
import com.xpand.starter.canal.annotation.CanalEventListener;
import com.xpand.starter.canal.annotation.ListenPoint;

import java.util.List;

@CanalEventListener()
public class ExpressListener {

    @ListenPoint(schema = "test", table = "express")
    public void ExpressUp(CanalEntry.EventType eventType, CanalEntry.RowData rowData) {
        System.out.println("快递表发生了改变");

        // 改变之前的数据信息集合
        List<CanalEntry.Column> beforeColumnsList = rowData.getBeforeColumnsList();

        // 便利改变之前的集合
        for (CanalEntry.Column c : beforeColumnsList) {
            System.out.println("改变之前的 数据:" + c.getName() + "::" + c.getValue());
        }
        System.out.println("=================================");
        //获取改变之后的数据
        rowData.getAfterColumnsList().forEach((c) -> System.out.println("改变之后的 数据:" + c.getName() + "::" + c.getValue()));

    }
}
